﻿using FS.Common.DotNetBean;
using FS.Common.DotNetCode;
using FS.Common.DotNetJson;
using FS.Common.DotNetUI;
using FS.Business;
using System;
using System.Data;
using System.Web;
using System.Web.SessionState;
using System.Text;

namespace FS.Web.BLL.Visa_info
{
    /// <summary>
    /// Summary description for EasySelect
    /// </summary>
    public class EasySelect : IHttpHandler, IRequiresSessionState
    {
        private visa_dao _visa = new visa_dao();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            context.Response.Buffer = true;
            context.Response.ExpiresAbsolute = DateTime.Now.AddDays(-1.0);
            context.Response.AddHeader("pragma", "no-cache");
            context.Response.AddHeader("cache-control", "");
            context.Response.CacheControl = "no-cache";

            string Action = context.Request["action"];           
            string cityid = context.Request["cityid"];
            string ls_infoid = context.Request["infoid"]; 
            string ls_beg = context.Request["begdate"];
            string ls_end = context.Request["enddate"];           

            string text = Action;
            if (text != null)
            {
                if (text == "citylist")    //国家信息
                {
                    DataTable dt = _visa.GetSelect_CityInfo();
                    string sb = JsonHelper.DataTableToJsonData(dt);

                    context.Response.Write(sb.ToString());
                    context.Response.End();
                }
                else if (text == "trustlist")    //资料齐全
                {
                    DataTable dt = _visa.GetSelect_TrustInfo();
                    string sb = JsonHelper.DataTableToJsonData(dt);

                    context.Response.Write(sb.ToString());
                    context.Response.End();
                }
                else if (text == "datalist")    //资料齐全
                {
                    DataTable dt = _visa.GetSelect_Dataintegrity();
                    string sb = JsonHelper.DataTableToJsonData(dt);

                    context.Response.Write(sb.ToString());
                    context.Response.End();
                }
                else if (text == "CityUser")    //城市用户
                {
                    DataTable dt = _visa.Ajax_GetCityUser(cityid);
                    string sb = JsonHelper.DataTableToJsonData(dt);

                    context.Response.Write(sb.ToString());
                    context.Response.End();
                }
                else if (text == "DetailList")    //城市用户
                {                    
                    DataTable dt = _visa.GetInfoDetail(ls_infoid);
                    //string sb = string.Concat("{\"total\":",
                    //    dt.Rows.Count.ToString(),
                    //    ",\"rows\":",
                    //    JsonHelper.DataTableToJsonData(dt),
                    //    "}"
                    //    )  ;
                    string sb = JsonHelper.DataTableToJsonData(dt);
                    context.Response.Write(sb.ToString());
                    context.Response.End();
                }
                else if (text == "calendarlist")    //工作日历
                {
                    DataTable dt = _visa.GetCalendarList(ls_beg, ls_end);
                    //string sb = string.Concat("{\"total\":",
                    //    dt.Rows.Count.ToString(),
                    //    ",\"rows\":",
                    //    JsonHelper.DataTableToJsonData(dt),
                    //    "}"
                    //    )  ;
                    string sb = JsonHelper.DataTableToJsonData(dt);
                    context.Response.Write(sb.ToString());
                    context.Response.End();
                }
                
            }
           
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}